#ifndef PERSISTOR_H
#define PERSISTOR_H

#include "../common/utils/Logger.h"
#include "../common/Constantes.h"
#include "./Scenario.h"
#include "./tinyxml/tinyxml.h"
#include <list>
#include "../common/DTOTipoAsteroide.h"
#include "../common/DTOAsteroide.h"
#include "TipoAsteroide.h"
#include "../SDLtoolkit/Asteroide.h"
#include "../SDLtoolkit/widgets/Ship.h"
#include "SDL/SDL.h"
#include "SDL/SDL_image.h"

#define PERSISTER_SUCCESS 0
#define INVALID_FILE -1
#define INVALID_ROOT_VALUE -2

class Persistor {

public:

	Persistor();

	static int getElements(std::list<Asteroide*>&, ShipStatus** shipStatus);

	static void getDimensions(int &width, int &height);

	~Persistor();
private:

	static std::stringstream logging;
    TiXmlElement *asteroide;

	static int getTiposAsteroide(TiXmlElement* root,std::list<DTOTipoAsteroide*>& tiposAsteroide);

	static int getAsteroides(TiXmlElement* root,std::list<DTOAsteroide*>& asteroides,std::list<DTOTipoAsteroide*>& tiposAsteroide);

	static int getShip(TiXmlElement* root,std::list<DTOShipStatus*>& ship);

	static DTOTipoAsteroide* findAsteroideType(std::string tipoString,std::list<DTOTipoAsteroide*>& tiposAsteroide);

	static bool existsAsteroideType(std::string tipoString,std::list<DTOTipoAsteroide*> tiposAsteroide);

	static void resolveOverlaping(const std::list<DTOAsteroide*>& asteroides,DTOShipStatus* dtoShipStatus);

	static bool isOverlapping(DTOAsteroide* asteroide,DTOShipStatus* dtoShipStatus);

	static int getRandValueInRange(bool isWidth);

	static SDL_Surface* loadSurface(std::string path);

};
#endif
